home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / om301.zip / OM.PAS < prev    next >
Pascal/Delphi Source File  |  1992-01-09  |  28KB  |  963 lines

  1. {OttoMenu 3.0 - Program Copyright (C) Doug Overmyer 12/17/91}
  2. {Begun 12/2/91} {Rel 3.0} {tabs = 2}
  3. program OttoMenu;
  4.  
  5. {$S-}{$R om.RES}{$R-}{$X+}{$V-}
  6. uses WinTypes,WinProcs,Strings,WObjects,WinDos,StdDlgs,
  7.     WFPlus,Buttons,SclpText;
  8. const
  9.   id_But1    = 201;     {User defined button 1 iconbar}
  10.   id_But2    = 202;     {      "             2 iconbar}
  11.   id_But3    = 203;     {      "             3 iconbar}
  12.   id_But4    = 204;     {      "             3 iconbar}
  13.   id_But5    = 205;     {      "             5 iconbar}
  14.   id_But6    = 206;     {User defined button 6 iconbar}
  15.   id_But7    = 207;     {      "             7 iconbar}
  16.   id_But8    = 208;     {      "             8 iconbar}
  17.   id_But9    = 209;     {      "             9 iconbar}
  18.   id_But10   = 210;     {      "            10 iconbar}
  19.   id_But11   = 211;
  20.   id_But12   = 212;
  21.   id_But13   = 213;
  22.   id_But14   = 214;
  23.   id_But15   = 215;
  24.   id_But21   = 221;     {page 1 icon}
  25.   id_But22   = 222;     {page 2 icon}
  26.   id_But23   = 223;     {page 3 icon}
  27.   id_But24   = 224;     {page 4 icon}
  28.   id_Gb1     = 300;     {group box for radio buttons}
  29.   id_GB2     = 200;     {group box for page icons}
  30.   id_D1Lb1   = 351;     {List box element in Dlg1}
  31.   id_St1     = 401;     {Static text 1         icon bar}
  32.   id_St2     = 402;     {Static text 2         icon bar}
  33.   id_D2OK    = 601;     {OK button in Dlg2     }
  34.   id_D2Browse= 650;     {Dlg2 Browse button}
  35.   id_D2EC1   = 603;     {Edit Control 1 in Dlg2 item #}
  36.   id_D2EC2   = 605;     {             2         Name}
  37.   id_D2EC3   = 607;     {             3         file}
  38.   id_D2EC4   = 609;     {             4         Start directory}
  39.   id_D2EC5   = 617;     {             5         parameters}
  40.   id_D2EC6   = 621;     {             6         start size}
  41.   id_D3LB1   = 701;
  42.  
  43.   idm_About  = 801;     {menu id for OM_About menu}
  44.   idm_MenuChange = 803;
  45.   idm_Run    =802;
  46. {************************  Types    ************************}
  47. type
  48. TOMApplication = object(TApplication)
  49.   procedure InitMainWindow;virtual;
  50. end;
  51.  
  52. type
  53. ItemRec = record
  54. ItemNum,PgmName,PgmFile,Dir,Params,Cmdshow:Array[0..69] of Char;
  55. end;
  56.  
  57. type
  58. PPgmItem = ^TPgmItem;
  59. TPgmItem = object(TObject)
  60.     PgmName:PChar;
  61.   PgmFile:PChar;
  62.   Dir:PChar;
  63.   Params:PChar;
  64.   CmdShow:PChar;
  65.   constructor Init(NewPgmName,NewPgmFile,NewDir,NewParams,NewCmdShow:PChar);
  66.   destructor Done;virtual;
  67. end;
  68.  
  69. POMDlg2 = ^TOMDlg2;
  70. TOMDlg2 = object(TDialog)              {Item setup dialog}
  71.   AnItem:ItemRec;
  72.     procedure WMInitDialog(var Msg:TMessage);virtual wm_First+wm_InitDialog;
  73.   procedure IDD2OK(var Msg:TMessage); virtual id_First+id_D2OK;
  74.   procedure IDD2EC1(var Msg:TMessage);virtual id_First+id_D2EC1;
  75.   procedure IDD2EC2(var Msg:TMessage);virtual id_First+id_D2EC2;
  76.   procedure IDD2EC3(var Msg:TMessage);virtual id_First+id_D2EC3;
  77.   procedure IDD2EC4(var Msg:TMessage);virtual id_First+id_D2EC4;
  78.   procedure IDD2EC5(var Msg:TMessage);virtual id_First+id_D2EC5;
  79.   procedure IDD2EC6(var Msg:TMessage);virtual id_First+id_D2EC6;
  80.   procedure LoadFields;
  81.   procedure IDBrowse(var Msg:TMessage);virtual id_First+id_D2Browse;
  82. end;
  83.  
  84. POMDlg3 = ^TOMDlg3;
  85. TOMDlg3 = object(TDialog)              {Item setup dialog}
  86.     procedure SetupWindow; virtual;
  87. end;
  88.  
  89.  
  90. POMAboutDlg = ^TOMAboutDlg;
  91. TOMAboutDlg = object(TDialog)
  92.   CurBrush:HBrush;
  93.   Is_Timer:Boolean;
  94.     procedure WMCtlColor(var Msg:TMessage);virtual wm_First+wm_CtlColor;
  95.   procedure SetupWindow;virtual;
  96.   procedure WMTimer(var Msg:TMessage);virtual wm_First+wm_Timer;
  97.   function CanClose:Boolean;virtual;
  98. end;
  99.  
  100. type                           {MainWindow of Application}
  101. POMWindow = ^TOMWindow;
  102. TOMWindow = object(TWindow)
  103.   TheIcon:HIcon;
  104.   BN:Array[0..15] of PODButton;  {icon bar button pointers}
  105.   BNR:Array[0..5] of PODRButton;
  106.   Gb1:PGroupBox;
  107.   GB2:PODGroupBox;
  108.   RB:Array[0..20] of PRadioButton; {radio button pointers id's 301-320}
  109.   St1,St2:PSText;
  110.   Apps:PCollection;
  111.   Br1,Br2:HBrush;
  112.   Logo:HBitmap;
  113.   PageNum,Max_Pages,AutoMin:Integer;
  114.   hUser,hGDI:THandle;
  115.   Helv:HFont;
  116.   Dlg3:POMDlg3;
  117.     constructor Init(AParent:PWindowsObject;ATitle:PChar);
  118.   destructor Done;virtual;
  119.   procedure SetupWindow;virtual;
  120.   procedure SetRBText;virtual;
  121.   procedure Paint(PaintDC:HDC;var PaintInfo:TPaintStruct);virtual;
  122.   procedure SetStaticText;
  123.   procedure    WMDrawItem(var Msg:TMessage);virtual wm_First + wm_DrawItem;
  124.   procedure IDBut1(var Msg:TMessage);virtual id_First+id_But1; { }
  125.     procedure IDBut2(var Msg:TMessage);virtual id_First+id_But2; { }
  126.   procedure IDBut3(var Msg:TMessage);virtual id_First+id_But3; { }
  127.   procedure    IDBut4(var Msg:TMessage);virtual id_First+id_But4; { }
  128.   procedure IDBut5(var Msg:TMessage);virtual id_First+id_But5; { }
  129.   procedure IDBut6(var Msg:TMessage);virtual id_First+id_But6; { }
  130.     procedure IDBut7(var Msg:TMessage);virtual id_First+id_But7; { }
  131.   procedure IDBut8(var Msg:TMessage);virtual id_First+id_But8; { }
  132.   procedure    IDBut9(var Msg:TMessage);virtual id_First+id_But9; { }
  133.   procedure IDBut10(var Msg:TMessage);virtual id_First+id_But10; { }
  134.     procedure IDBut11(var Msg:TMessage);virtual id_First+id_But11; { }
  135.   procedure IDBut12(var Msg:TMessage);virtual id_First+id_But12; { }
  136.   procedure    IDBut13(var Msg:TMessage);virtual id_First+id_But13; { }
  137.   procedure IDBut14(var Msg:TMessage);virtual id_First+id_But14; { }
  138.   procedure    IDBut21(var Msg:TMessage);virtual id_First+id_But21; {Page1}
  139.   procedure IDBut22(var Msg:TMessage);virtual id_First+id_But22; {Page2}
  140.   procedure    IDBut23(var Msg:TMessage);virtual id_First+id_But23; {Page3}
  141.   procedure IDBut24(var Msg:TMessage);virtual id_First+id_But24; {Page4}
  142.   procedure IDBut15(var Msg:TMessage);virtual id_First+id_But15; {Free Icon}
  143.   procedure DefChildProc(var Msg:TMessage);virtual;
  144.   procedure WinExecc(var Msg:TMessage);virtual;
  145.   procedure    WMSysCommand(var Msg:TMessage);virtual wm_First+wm_SysCommand;
  146.   procedure GetItemValues(var AnItem:ItemRec);virtual;
  147.   procedure SetItemValues(AnItem:ItemRec);virtual;
  148.   procedure GetItems;virtual;
  149.     procedure WMCtlColor(var Msg:TMessage);virtual wm_First+wm_CtlColor;
  150.   procedure RunIt;virtual;
  151. end;
  152. {***********************  Globals     ******************************}
  153. var
  154.     MainWin:POMWindow;
  155. {***********************  Methods    *******************************}
  156. procedure TOMApplication.InitMainWindow;
  157. begin
  158.     MainWindow := New(POMWindow,Init(nil,'OttoMenu'));
  159.   MainWin := POMWindow(MainWindow);
  160. end;
  161. {**********************  TOMWindow  *******************************}
  162. constructor TOMWindow.Init(AParent:PWindowsObject;ATitle:PChar);
  163. Const
  164.     BMP:Array[0..25] of PChar = ('','OM_B4','OM_B1','OM_B9','OM_B8','OM_B10',
  165.   'OM_B7','OM_B3','OM_B11','OM_B12','OM_B13',
  166.   'OM_B2','OM_B14','OM_B15', 'OM_B6', 'OM_B5',
  167.   '','','','','',
  168.   'OM_B21', 'OM_B22','OM_B23','OM_B24','');
  169. var
  170.   TheBmp:HBitmap;
  171.   Buf:Array[0..25] of Char;
  172.   Indx:Integer;
  173. begin
  174.     TWindow.Init(AParent,ATitle);
  175.   Attr.Menu := 0; {LoadMenu(HInstance,'OM_Menu');}
  176.   Attr.X := 20; Attr.Y := 25; Attr.W := 595; Attr.H := 325;
  177.   Attr.Style := ws_Overlapped or ws_SysMenu or ws_MinimizeBox;
  178.     Max_Pages :=Min(4,GetPrivateProfileInt('OM','MaxPages',4,'OM.INI'));
  179.   For Indx := 0 to 11 do BN[Indx] := nil;
  180.   For Indx := 0 to 4 do BNR[Indx] := nil;
  181.   For Indx := 0 to 20 do RB[Indx] := nil;
  182.   For Indx := 1 to 10 do
  183.       BN[Indx]:=New(PODButton,Init(@Self,200+Indx,'',(Indx-1)*34,0,34,34,False,BMP[Indx]));
  184.     For Indx := 11 to 15 do
  185.       BN[Indx]:=New(PODButton,Init(@Self,200+Indx,'',(Indx-11)*34+0,35,34,34,False,BMP[Indx]));
  186.   Gb2 := New(PODGroupBox,Init(@Self,id_Gb2,'',0,35,34,34));
  187.   GB2^.Attr.Style := GB2^.Attr.Style and not ws_Visible;
  188.   For Indx := 1 to Max_Pages do
  189.         BNR[Indx] := New(PODRButton,Init(@Self,Indx+220,'',0,35,34,34,GB2,BMP[Indx+20]));
  190.   St1 := New(PSText,Init(@Self,id_St1,'',345,5,245,25,sr_Recessed,
  191.               dt_Center or dt_VCenter or dt_SingleLine));
  192.   GB1 := New(PGroupBox,Init(@Self,id_Gb1,'Applications',200,50,350,230));
  193.   For Indx := 1 to 10 do
  194.       RB[Indx]:=New(PRadioButton,Init(@Self,(300+Indx),'',215,(75+(Indx-1)*20),160,20,GB1));
  195.   For Indx := 11 to 20 do
  196.       RB[Indx]:=New(PRadioButton,Init(@Self,(300+Indx),'',385,(75+(Indx-11)*20),160,20,GB1));
  197.   Apps := New(PCollection,Init(81,20));
  198.   PageNum := 1;
  199.   TheBmp :=LoadBitmap(HInstance,'OM_Br1');
  200.   Br1 :=CreatePatternBrush(TheBmp);
  201.   DeleteObject(TheBmp);
  202.   theBmp :=LoadBitmap(HInstance,'OM_Br2');
  203.   Br2 :=CreatePatternBrush(TheBmp);
  204.   DeleteObject(theBmp);
  205.     GetPrivateProfileString('OM','CPU','Otto',Buf,SizeOf(Buf),'OM.INI');
  206.     AutoMin :=Min(2,GetPrivateProfileInt('OM','AutoMin',0,'OM.INI'));
  207.   if StrIComp(Buf,'ECO')= 0 then
  208.     Logo :=LoadBitmap(HInstance,'OM_Logo')
  209.   else if StrIComp(Buf,'MIS') = 0 then
  210.       Logo :=LoadBitmap(HInstance,'OM_Logo2')
  211.   else
  212.     Logo :=LoadBitmap(HInstance,'OM_Logo3');
  213.   BNR[1]^.State := 1;
  214.   GB2^.SelectionChanged(id_But21);
  215. end;
  216.  
  217. procedure TOMWindow.SetupWindow;
  218. var
  219.     SysMenu:hMenu;
  220.   Indx:Word;
  221.   CR:TRect;
  222.   NewTop:Integer;
  223.   LogFont:TLogFont;
  224.   DC:hDC;
  225.     LogPixY:Integer;
  226.   Msg:TMessage;
  227. begin
  228.     TWindow.SetupWindow;
  229.     SetClassWord(HWindow,GCW_HIcon,LoadIcon(HInstance,'OM_Icon'));
  230.   SetClassWord(HWindow,GCW_HBrBackGround,Br1);
  231.   Sysmenu := GetSystemMenu(hWindow,false);
  232.   AppendMenu(SysMenu,MF_Separator,0,nil);
  233.   AppendMenu(Sysmenu,0,idm_Run,'Run...');
  234.   AppendMenu(Sysmenu,0,idm_MenuChange,'Menu Maintenance...');
  235.   AppendMenu(Sysmenu,0,idm_About,'About...');
  236.   GetClientRect(HWindow,CR);
  237.   NewTop := CR.Bottom-Cr.Top-34;
  238.   for Indx := 1  to 4 do
  239.       if BNR[Indx] <> nil then
  240.         begin
  241.         MoveWindow(BNR[Indx]^.HWindow,34*(Indx-1),NewTop,34,34,False);
  242.       MoveWindow(GB2^.HWindow,0,NewTOP,34*(Indx),34,False);
  243.       end;
  244.   hUser := LoadLibrary('User.exe');
  245.   FreeLibrary(hUser);
  246.   hGDI := LoadLibrary('GDI.exe');
  247.   FreeLibrary(hGDI);
  248.  
  249.   DC := GetDC(HWindow);
  250.   LogPixY :=GetDeviceCaps(DC,LogPixelsY);
  251.   ReleaseDC(HWindow,DC);
  252.  
  253.   GetObject(GetStockObject(System_Font),sizeof(LogFont),@LogFont);
  254.   StrCopy(LogFont.lfFaceName,'Helv');
  255.     LogFont.lfHeight := round(LogFont.lfHeight * 2 / 3);
  256.   LogFont.lfWidth := 0;
  257.   LogFont.lfPitchAndFamily := 0;
  258.   Helv := CreateFontIndirect(LogFont);
  259.  
  260.   SetStaticText;
  261.   GetItems;
  262.   SetRBText;
  263. end;
  264.  
  265. procedure TOMWindow.SetStaticText;
  266. var
  267.   Buf:Array[0..55] of Char;
  268.   Mem :Record
  269.       GlobalFreeMem,User,GDI:LongInt;
  270.   end;
  271.   PageNumBuf:Array[0..25] of Char;
  272.   LogFont:TLogFont;
  273.   NewFont,OldFont:HFont;
  274. begin
  275.     Mem.User :=Round((65536 - GlobalSize(hUser)) / 1024);
  276.   Mem.GDI := Round((65536 -GlobalSize(hGDI)) / 1024);
  277.     Mem.GlobalFreeMem := Round(GetFreeSpace(0) / 1024);
  278.   wvsprintf(Buf,'GMem:%luK  USeg:%luK  GDISeg:%liK',Mem);
  279.  
  280.     St1^.SetFont(Helv);
  281.   St1^.SetText(Buf);
  282.   Str(PageNum,PageNumBuf);
  283.   StrCat(StrCopy(Buf,'Page: '),PageNumBuf);
  284.   SetWindowText(GB1^.HWindow,Buf);
  285. end;
  286.  
  287. procedure TOMWindow.GetItems;
  288. var
  289.     Buf1:Array[0..30] of Char;
  290.   Indx:Integer;
  291.   IndxStr:Array[0..5] of Char;
  292.   Found:Boolean;
  293.   Key:Array[0..20] of Char;
  294.   PgmName,PgmFile,Dir,Params:Array[0..50] of Char;
  295.   CmdShow:Array[0..5] of Char;
  296. begin
  297.   for Indx := 0 to 20*Max_Pages do
  298.       begin
  299.     StrCopy(PgmFile,'');Strcopy(Dir,'');StrCopy(Params,'');StrCopy(CmdShow,'');
  300.     Str(Indx,IndxStr);
  301.     StrCat(StrCopy(Key,'PgmName'),IndxStr);
  302.         GetPrivateProfileString('OM',Key,'',PgmName,SizeOf(PgmName),'OM.INI');
  303.     if PgmName[0] <> #0 then
  304.         begin
  305.         StrCat(StrCopy(Key,'PgmFile'),IndxStr);
  306.             GetPrivateProfileString('OM',Key,'',PgmFile,SizeOf(PgmFile),'OM.INI');
  307.         StrCat(StrCopy(Key,'Dir'),IndxStr);
  308.             GetPrivateProfileString('OM',Key,'',Dir,SizeOf(dir),'OM.INI');
  309.         StrCat(StrCopy(Key,'Params'),IndxStr);
  310.             GetPrivateProfileString('OM',Key,'',Params,SizeOf(Params),'OM.INI');
  311.         StrCat(StrCopy(Key,'CmdShow'),IndxStr);
  312.             GetPrivateProfileString('OM',Key,'',Cmdshow,SizeOf(CmdShow),'OM.INI');
  313.         end;
  314.     Apps^.AtInsert(Indx,New(PPgmItem,Init(PgmName,PgmFile,Dir,Params,Cmdshow)));
  315.     end;
  316. end;
  317.  
  318. procedure TOMWindow.SetRBText;
  319. var
  320.     Offset:Integer;
  321.     ChildWin:PRadioButton;
  322.   Indx:Integer;
  323.   Item:PPgmItem;
  324. begin
  325.     Offset := (PageNum-1)*20;
  326.     For Indx := Offset+1 to Offset+20 do
  327.       begin
  328.     Item := Apps^.At(Indx);
  329.     SetWindowText(RB[Indx-OffSet]^.HWindow,Item^.PgmName);
  330.       end;
  331. end;
  332.  
  333. destructor TOMWindow.Done;
  334. begin
  335.     DeleteObject(Helv);
  336.   Dispose(Apps,Done);
  337.   DeleteObject(Logo);
  338.     If HPrevInst = 0 then
  339.       begin
  340.         DeleteObject(Br1);
  341.       DeleteObject(Br2);
  342.       end;
  343.   TWindow.Done;
  344. end;
  345.  
  346. procedure TOMWindow.Paint(PaintDC:HDC;var PaintInfo:TPaintStruct);
  347. var
  348.     ThePen:HPen;
  349.   TheBrush :HBrush;
  350.   OldBrush :HBrush;
  351.   OldPen:HPen;
  352.   MemDC:hDC;
  353.   OldBitmap:HBitmap;
  354.   CR:TRect;
  355.   X1,Y1,X2,Y2:Integer;
  356.   Pen1:HPen;
  357.   Pen2:HPen;
  358. begin
  359.     X1:=190;Y1:=48;X2:=560;Y2:=290;
  360.     TheBrush := GetStockObject(LtGray_Brush);
  361.     ThePen := CreatePen(ps_Solid,1,$00000000);
  362.   OldPen := SelectObject(PaintDC,ThePen);
  363.   OldBrush := SelectObject(PaintDC,TheBrush);
  364.   Rectangle(PaintDC,0,0,1024,35);
  365.   SelectObject(PaintDC,OldBrush);
  366.   SelectObject(PaintDC,OldPen);
  367.   DeleteObject(ThePen);
  368.   DeleteObject(TheBrush);
  369.   SRectangle(PaintDC,X1,Y1,X2,Y2,2,sr_Recessed);
  370.   MemDC := CreateCompatibleDC(PaintDC);
  371.   OldBitmap := SelectObject(MemDC,Logo);
  372.   BitBlt(PaintDC,25,100,125,125,MemDc,0,0,SrcCopy);
  373.   SelectObject(MemDC,OldBitmap);
  374.   DeleteDC(MemDc);
  375. end;
  376.  
  377. procedure    TOMWindow.WMDrawItem(var Msg:TMessage);
  378. var
  379.     PDIS : ^TDrawItemStruct;
  380. begin
  381.     PDIS := Pointer(Msg.lParam);
  382.     case PDIS^.CtlType of
  383.         odt_Button:
  384.         case PDIS^.CtlID of
  385.             id_But1..id_But15:Bn[PDIS^.CtlID-200]^.DrawItem(Msg);
  386.             id_But21..id_But24:BnR[PDIS^.CtlID-220]^.DrawItem(Msg);
  387.         end;
  388.     end;
  389. end;
  390.  
  391. procedure TOMWindow.IDBut1(var Msg:TMessage);
  392. begin
  393.     WinExec('progman.exe',sw_Normal);
  394. end;
  395.  
  396. procedure TOMWindow.IDBut2(var Msg:TMessage);
  397. begin
  398.     WinExec('winfile.exe',sw_Normal);
  399. end;
  400.  
  401. procedure TOMWindow.IDBut3(var Msg:TMessage);
  402. begin
  403.     WinExec('clipbrd.exe',sw_Normal);
  404. end;
  405.  
  406. procedure TOMWindow.IDBut4(var Msg:TMessage);
  407. begin
  408.     WinExec('control.exe',sw_Normal);
  409. end;
  410.  
  411. procedure TOMWindow.IDBut5(var Msg:TMessage);
  412. begin
  413.     winExec('printman.exe',sw_Normal);
  414. end;
  415.  
  416. procedure TOMWindow.IDBut6(var Msg:TMessage);
  417. begin
  418.     WinExec('pifedit.exe',sw_Normal);
  419. end;
  420.  
  421. procedure TOMWindow.IDBut7(var Msg:TMessage);
  422. begin
  423.   WinExec('notepad.exe',sw_Normal);
  424. end;
  425.  
  426. procedure TOMWindow.IDBut8(var Msg:TMessage);
  427. begin
  428.   WinExec('pbrush.exe',sw_Normal);
  429. end;
  430.  
  431. procedure TOMWindow.IDBut9(var Msg:TMessage);
  432. begin
  433.   WinExec('sysedit.exe',sw_Normal);
  434. end;
  435.  
  436. procedure TOMWindow.IDBut10(var Msg:TMessage);
  437. begin
  438.   WinExec('setup.exe',sw_Normal);
  439. end;
  440.  
  441. procedure TOMWindow.IDBut11(var Msg:TMessage);
  442. var
  443.     Item:PPgmItem;
  444. begin
  445.     Item := Apps^.At(0);
  446.     if (Item^.Dir <> NIL) then
  447.           SetCurdir(Item^.Dir);
  448.   if (Item^.PgmFile <> nil) then
  449.       WinExec(Item^.PgmFile,sw_Normal)
  450.   else
  451.         WinExec('command.com',sw_Normal);
  452. end;
  453.  
  454. procedure TOMWindow.IDBut12(var Msg:TMessage);
  455. begin
  456.     Dlg3 := New(POMDlg3,Init(@Self,'Om_Dlg3'));
  457.     Application^.ExecDialog(Dlg3);
  458. end;
  459.  
  460. procedure TOMWindow.IDBut13(var Msg:TMessage);
  461. begin
  462.     SetStaticText;
  463. end;
  464.  
  465. procedure TOMWindow.IDBut14(var Msg:TMessage);
  466. begin
  467.     CloseWindow;
  468. end;
  469.  
  470. procedure TOMWindow.IDBut15(var Msg:TMessage);
  471. begin
  472.   ExitWindows(0,0);
  473. end;
  474.  
  475. procedure TOMWindow.IDBut21(var Msg:TMessage);
  476. begin
  477.   PageNum := 1;
  478.   SetRBText;
  479.   SetStaticText;
  480. end;
  481. procedure TOMWindow.IDBut22(var Msg:TMessage);
  482. begin
  483.   PageNum := Min(2,Max_Pages);
  484.   SetRBText;
  485.   SetStaticText;
  486. end;
  487. procedure TOMWindow.IDBut23(var Msg:TMessage);
  488. begin
  489.   PageNum := Min(3,Max_pages);
  490.   SetRBText;
  491.   SetStaticText;
  492. end;
  493. procedure TOMWindow.IDBut24(var Msg:TMessage);
  494. begin
  495.   PageNum := Min(4,Max_Pages);
  496.   SetRBText;
  497.   SetStaticText;
  498. end;
  499.  
  500.  
  501.  
  502. procedure TOMWindow.DefChildProc(var Msg:TMessage);
  503. var
  504.     ID:Integer;
  505. begin
  506.     ID := Msg.WParam-300 + 20*(PageNum-1);
  507.     If (Msg.WParam > id_GB1) and
  508.        (Msg.WParam < (id_GB1+21)) and
  509.      (ID < Apps^.Count) then
  510.       WinExecc(Msg)
  511.   else
  512.       TWindow.DefChildProc(Msg);
  513. end;
  514.  
  515. procedure TOMWindow.WinExecc(var Msg:TMessage);
  516. var
  517.     ID:Integer;
  518.     Item:PPgmItem;
  519.   Buf:Array[0..100] of Char;
  520.   Errval:Integer;
  521.   nCmdShow,CmdShow:Integer;
  522. begin
  523.     ID := Msg.WParam-300 + 20*(PageNum-1);
  524.     Item := Apps^.At(ID);
  525.   if (Item^.PgmFile = NIL) then
  526.       begin
  527.       RB[Msg.WParam-300]^.Toggle;
  528.     TWindow.DefChildProc(Msg);
  529.     Exit;
  530.     end;
  531.  
  532.   StrCopy(Buf,Item^.PgmFile);
  533.   if (Item^.Params <> NIL) then
  534.           StrCat(StrCat(Buf,' '),Item^.Params);
  535.   if (Item^.Cmdshow <> NIL) then
  536.       case Item^.CmdShow[0] of
  537.         'N','n':Cmdshow := sw_Normal;
  538.       'M','m':CmdShow := sw_Maximize;
  539.       'I','i':CmdShow := sw_Minimize;
  540.         else
  541.           CmdShow := sw_Normal;
  542.     end;
  543.     if (Item^.Dir <> NIL) then
  544.       SetCurdir(Item^.Dir);
  545.   WinExec(Buf,CmdShow);
  546.     RB[Msg.WParam-300]^.Toggle;
  547.   If AutoMin = 1 then
  548.       ShowWindow(HWindow,sw_Minimize);
  549. end;
  550.  
  551. procedure    TOMWindow.WMSysCommand(var Msg:TMessage);
  552. begin
  553.     case Msg.Wparam of
  554.         idm_About:
  555.             Application^.ExecDialog(New(POMAboutDlg,Init(@Self,'OM_About')));
  556.     idm_MenuChange:
  557.         Application^.ExecDialog(New(POMDlg2,Init(@Self,'Om_Dlg2')));
  558.     idm_Run:
  559.         Runit;
  560.        else
  561.            DefWndProc(Msg);
  562.        end;
  563. end;
  564.  
  565. procedure TOMWindow.GetItemValues(var AnItem:ItemRec);
  566. var
  567.     Buf1:Array[0..30] of Char;
  568.   Indx:Integer;
  569.   IndxStr:Array[0..5] of Char;
  570.   Key:Array[0..20] of Char;
  571.   ErrCode:Integer;
  572.   TheItem:PPgmItem;
  573. begin
  574.     Val(AnItem.ItemNum,Indx,ErrCode);
  575.   if ErrCode <> 0 then
  576.       Exit;
  577.   If Indx > Max_Pages*20 then
  578.       Exit;
  579.   begin
  580.   TheItem := Apps^.At(Indx);
  581.   If TheItem^.PgmName <> nil then
  582.       StrCopy(AnItem.PgmName,TheItem^.PgmName);
  583.   If TheItem^.PgmFile <> nil then
  584.       StrCopy(AnItem.PgmFile,TheItem^.PgmFile);
  585.   If TheItem^.Dir <> nil then
  586.       StrCopy(AnItem.Dir,TheItem^.Dir);
  587.   If TheItem^.Params <> nil then
  588.       StrCopy(AnItem.Params,TheItem^.Params);
  589.   If TheItem^.Cmdshow <> nil then
  590.       StrCopy(AnItem.CmdShow,TheItem^.Cmdshow);
  591.     end;
  592. end;
  593.  
  594. procedure TOMWindow.SetItemValues(AnItem:ItemRec);
  595. var
  596.     Buf1:Array[0..30] of Char;
  597.   Indx:Integer;
  598.   IndxStr:Array[0..5] of Char;
  599.   Found:Boolean;
  600.   Key:Array[0..20] of Char;
  601.   Errval:Integer;
  602. begin
  603.     Val(AnItem.ItemNum,Indx,Errval);
  604.   If Indx <= 20*Max_Pages then
  605.       begin
  606.       StrCopy(IndxStr,AnItem.ItemNum) ;
  607.     StrCat(StrCopy(Key,'PgmName'),IndxStr);
  608.         WritePrivateProfileString('OM',Key,AnItem.PgmName,'OM.INI');
  609.     StrCat(StrCopy(Key,'PgmFile'),IndxStr);
  610.         WritePrivateProfileString('OM',Key,AnItem.PgmFile,'OM.INI');
  611.     StrCat(StrCopy(Key,'Dir'),IndxStr);
  612.         WritePrivateProfileString('OM',Key,AnItem.Dir,'OM.INI');
  613.     StrCat(StrCopy(Key,'Params'),IndxStr);
  614.         WritePrivateProfileString('OM',Key,AnItem.Params,'OM.INI');
  615.     StrCat(StrCopy(Key,'CmdShow'),IndxStr);
  616.         WritePrivateProfileString('OM',Key,AnItem.CmdShow,'OM.INI');
  617.     Apps^.AtFree(Indx);
  618.     Apps^.AtInsert(Indx,New(PPgmItem,Init(AnItem.PgmName,AnItem.PgmFile,
  619.         AnItem.Dir,AnItem.Params,AnItem.Cmdshow)));
  620.     SetRBText;
  621.     end;
  622. end;
  623.  
  624. procedure TOMWindow.WMCTLCOLOR(var Msg: TMessage);
  625. const
  626.   as_AboutSt1 =   126;  {about dlg static text   }
  627.   as_AboutSt2 =   128;  {about dlg static blank static to draw upon}
  628. var
  629.     HSt1,HSt2:HWnd;
  630.   MemDC:hDC;
  631.   OldBitmap:HBitmap;
  632.   CR:TRect;
  633.   X,Y,W,H:Integer;
  634.   LogoMetrics:TBitmap;
  635. begin
  636.   case Msg.LParamHi of
  637.     ctlcolor_Btn:
  638.       begin
  639.       SetBkMode(Msg.WParam, Transparent);
  640.       Msg.Result := GetStockObject(ltGray_Brush);
  641.       end;
  642.   else
  643.     DefWndProc(Msg);
  644.   end;
  645. end;
  646.  
  647. procedure TOMWindow.Runit;
  648. var
  649.     Dlg1 :PFileDialog;
  650.     App:Array[0..69] of Char;
  651.   Path,Dir,Ext:Array[0..79] of Char;
  652.   OldDir:Array[0..79] of Char;
  653. begin
  654.     StrCopy(App,'*.*');
  655.   Dlg1 := new(PfileDialog,Init(@Self,PChar(sd_FileOpen),@App));
  656.   Dlg1^.Caption := 'Select Program';
  657.   GetCurDir(Olddir,0);
  658.   If Application^.ExecDialog(Dlg1) = id_OK then
  659.       begin
  660.     filesplit(App,Path,Dir,Ext);
  661.     SetCurDir(Path);
  662.       WinExec(App,sw_Normal);
  663.     SetCurdir(OldDir);
  664.       If AutoMin = 1 then
  665.           ShowWindow(HWindow,sw_Minimize);
  666.     end;
  667. end;
  668.  
  669. {***********************  TOMDlg2  ******************************}
  670. procedure TOMDlg2.WMInitDialog(var Msg:TMessage);
  671. begin
  672.     StrCopy(AnItem.ItemNum,'');
  673.   StrCopy(AnItem.PgmName,'');
  674.   StrCopy(AnItem.PgmFile,'');
  675.   StrCopy(AnItem.Dir,'');
  676.   Strcopy(AnItem.Params,'');
  677.   StrCopy(AnItem.CmdShow,'');
  678. end;
  679.  
  680. procedure TOMDlg2.IDD2OK(var Msg:TMessage);
  681. begin
  682.   MainWin^.SetItemValues(AnItem);
  683.   EndDlg(1);
  684. end;
  685.  
  686. procedure TOMDlg2.IDD2EC1(var Msg:TMessage);
  687. var
  688.   Buf:Array[0..69] of Char;
  689.   Ptr : PChar;
  690.   ErrCode:Integer;
  691.   Margin:Real;
  692.   return:Integer;
  693. begin
  694.     case Msg.lParamHi of
  695.     en_KillFocus:
  696.            begin
  697.       Ptr := Buf;
  698.       Return := SendDlgItemMsg(id_D2EC1,wm_GetText,word(69),LongInt(Ptr));
  699.             StrCopy(AnItem.ItemNum,Ptr);
  700.       LoadFields;
  701.       end;
  702.   end;
  703. end;
  704.  
  705. procedure TOMDlg2.IDD2EC2(var Msg:TMessage);
  706. var
  707.   Buf:Array[0..69] of Char;
  708.   Ptr : PChar;
  709.   return:Integer;
  710. begin
  711.     case Msg.lParamHi of
  712.     en_KillFocus:
  713.            begin
  714.       Ptr := Buf;
  715.       Return := SendDlgItemMsg(id_D2EC2,wm_GetText,word(69),LongInt(Ptr));
  716.       StrCopy(AnItem.PgmName,Ptr);
  717.       end;
  718.   end;
  719. end ;
  720.  
  721. procedure TOMDlg2.IDD2EC3(var Msg:TMessage);
  722. var
  723.   Buf:Array[0..69] of Char;
  724.   Ptr : PChar;
  725.   return:Integer;
  726. begin
  727.     case Msg.lParamHi of
  728.     en_KillFocus:
  729.            begin
  730.       Ptr := Buf;
  731.       Return := SendDlgItemMsg(id_D2EC3,wm_GetText,word(69),LongInt(Ptr));
  732.       StrCopy(AnItem.PgmFile,Ptr);
  733.       end;
  734.   end;
  735. end;
  736.  
  737. procedure TOMDlg2.IDD2EC4(var Msg:TMessage);
  738. var
  739.   Buf:Array[0..69] of Char;
  740.   Ptr : PChar;
  741.   return:Integer;
  742. begin
  743.     case Msg.lParamHi of
  744.     en_KillFocus:
  745.            begin
  746.       Ptr := Buf;
  747.       Return := SendDlgItemMsg(id_D2EC4,wm_GetText,word(69),LongInt(Ptr));
  748.       StrCopy(AnItem.Dir,Ptr);
  749.       end;
  750.   end;
  751. end;
  752.  
  753. procedure TOMDlg2.IDD2EC5(var Msg:TMessage);
  754. var
  755.   Buf:Array[0..69] of Char;
  756.   Ptr : PChar;
  757.   return:Integer;
  758. begin
  759.     case Msg.lParamHi of
  760.     en_KillFocus:
  761.             begin
  762.       Ptr := Buf;
  763.       Return := SendDlgItemMsg(id_D2EC5,wm_GetText,word(69),LongInt(Ptr));
  764.       StrCopy(AnItem.Params,Ptr);
  765.       end;
  766.   end;
  767. end;
  768.  
  769. procedure TOMDlg2.IDD2EC6(var Msg:TMessage);
  770. var
  771.   Buf:Array[0..69] of Char;
  772.   Ptr : PChar;
  773.   return:Integer;
  774. begin
  775.     case Msg.lParamHi of
  776.     en_KillFocus:
  777.         begin
  778.       Ptr := Buf;
  779.       Return := SendDlgItemMsg(id_D2EC6,wm_GetText,word(69),LongInt(Ptr));
  780.       StrCopy(AnItem.CmdShow,Ptr);
  781.       end;
  782.    end;
  783. end;
  784.  
  785. procedure TOMDlg2.LoadFields;
  786. var
  787.     pBuf:Pchar;
  788. begin
  789.     MainWin^.GetItemValues(AnItem);
  790.   pBuf := AnItem.PgmName;
  791.   SendDlgItemMsg(id_D2Ec2,wm_SetText,0,LongInt(pBuf));
  792.   pBuf := AnItem.PgmFile;
  793.   SendDlgItemMsg(id_D2Ec3,wm_SetText,0,LongInt(pBuf));
  794.   pBuf := AnItem.Dir;
  795.   SendDlgItemMsg(id_D2Ec4,wm_SetText,0,LongInt(pBuf));
  796.   pBuf := AnItem.Params;
  797.   SendDlgItemMsg(id_D2Ec5,wm_SetText,0,LongInt(pBuf));
  798.   pBuf := AnItem.CmdShow;
  799.   SendDlgItemMsg(id_D2Ec6,wm_SetText,0,LongInt(pBuf));
  800.   EnableWindow(GetItemHandle(id_D2Browse),True);
  801. end;
  802.  
  803. procedure TOMDlg2.IDBrowse(var Msg:TMessage);
  804. var
  805.     Dlg1 :PFileDialog;
  806.     App:Array[0..69] of Char;
  807.   pBuf:PChar;
  808.   Dir,Name,Ext:Array[0..69] of Char;
  809. begin
  810.     StrCopy(App,'*.*');
  811.   Dlg1 := new(PfileDialog,Init(@Self,PChar(sd_FileOpen),@App));
  812.   Dlg1^.Caption := 'Select Program';
  813.   If Application^.ExecDialog(Dlg1) = id_OK then
  814.       begin
  815.     FileSplit(App,Dir,Name,Ext);
  816.     Name[0] := UpCase(Name[0]);
  817.     pBuf := Name;
  818.       SendDlgItemMsg(id_D2Ec2,wm_SetText,0,LongInt(pBuf));
  819.     StrCopy(AnItem.PgmName,pBuf);
  820.     pBuf := App;
  821.       SendDlgItemMsg(id_D2Ec3,wm_SetText,0,LongInt(pBuf));
  822.     StrCopy(AnItem.PgmFile,pBuf);
  823.     SetFocus(GetItemHandle(id_D2Ec4));
  824.     end;
  825. end;
  826.  
  827. procedure TOMDlg3.SetupWindow;
  828. var
  829.     Dr:Char;
  830.   ArgList : record
  831.       StrPtr : PChar;
  832.       Free:PChar;
  833.       Size:LongInt;
  834.       PctFree:LongInt;
  835.   end;
  836.   szFree:Array[0..5] of Char;
  837.   rFree:Real;
  838.   szDr:Array[0..2] of Char;
  839.   szOutput : Array[0..80] of Char;
  840. begin
  841.     SendMessage(MainWin^.Dlg3^.GetItemHandle(Id_D3Lb1),wm_SetFont,GetStockObject(OEM_Fixed_Font),0);
  842.     DosError := 0; StrCopy(szOutput,'');
  843.   WVSPrintf(szOutput,'Dr  MBf  MBt %%Free',ArgList);
  844.   SendMessage(MainWin^.Dlg3^.GetItemHandle(Id_D3Lb1),lb_AddString,0,LongInt(@szOutput));
  845.  
  846.   Dr := 'C';
  847.   szDr[0] := Dr; szDr[1] := #0;
  848.   while DosError = 0 do
  849.        begin
  850.     SetCurDir(StrCat(szDr,':'));
  851.       if DosError = 0 then
  852.           begin
  853.         rFree := (DiskFree(0) / 1024 / 1024);
  854.         Str(rFree:4:1,szFree);
  855.         ArgList.Free := @szFree;
  856.         ArgList.Size := Round( DiskSize(0) / 1024 /1024) ;
  857.         ArgList.PctFree := Round(DiskFree(0) / (DiskSize(0) / 100 )) ;
  858.         ArgList.StrPtr := @szDr;
  859.         WVSPrintf(szOutput,'%s %s  %3li  %3li',ArgList);
  860.         SendMessage(MainWin^.Dlg3^.GetItemHandle(Id_D3Lb1),lb_AddString,0,LongInt(@szOutput));
  861.         end;
  862.     Inc(Dr);
  863.     szDr[0] := Dr;
  864.     szDr[1] := #0;
  865.     end;
  866. end;
  867. {********************  TOMAbout     **************************}
  868. procedure TOMAboutDlg.WMCTLCOLOR(var Msg: TMessage);
  869. const
  870.   as_AboutSt1 =   126;  {about dlg static text   }
  871.   as_AboutSt2 =   128;  {about dlg static blank static to draw upon}
  872. var
  873.     HSt1,HSt2:HWnd;
  874.   MemDC:hDC;
  875.   OldBitmap:HBitmap;
  876.   CR:TRect;
  877.   X,Y,W,H:Integer;
  878.   LogoMetrics:TBitmap;
  879. begin
  880.   case Msg.LParamHi of
  881.     ctlColor_Static:
  882.       begin
  883.         If (as_AboutSt1 = GetDlgCtrlID(Msg.lParamLo)) then
  884.             SetTextColor(Msg.WParam, RGB(0,0,255))
  885.         else  if (as_AboutSt2 = GetDlgCtrlID(Msg.lParamLO)) then
  886.             begin
  887.           MemDC := CreateCompatibleDC(Msg.WParam);
  888.           OldBitmap := SelectObject(MemDC,MainWin^.Logo);
  889.           GetClientRect(Msg.lParamLo,CR);
  890.           W:= CR.Right-CR.Left;H:= CR.Bottom-CR.Top;
  891.           GetObject(MainWin^.Logo,SizeOf(LogoMetrics),@LogoMetrics);
  892.           X := Max((W - LogoMetrics.bmWidth) div 2 , 0);
  893.           Y := Max((H - LogoMetrics.bmHeight) div 2 , 0);
  894.           BitBlt(Msg.WParam,X,Y,W,H,MemDc,0,0,SrcCopy);
  895.           SelectObject(MemDC,OldBitmap);
  896.           DeleteDC(MemDc);
  897.           end;
  898.         SetBkMode(Msg.WParam, transparent);
  899.         Msg.Result := GetStockObject(Null_Brush);
  900.       end;
  901.     ctlcolor_Dlg:
  902.       begin
  903.         SetBkMode(Msg.WParam, Transparent);
  904.         If CurBrush = MainWin^.Br1 then
  905.             CurBrush := MainWin^.Br2
  906.         else
  907.             CurBrush := MainWin^.Br1;
  908.         Msg.Result := CurBrush;
  909.       end;
  910.   else
  911.     DefWndProc(Msg);
  912.   end;
  913. end;
  914.  
  915. procedure TOMAboutDlg.SetupWindow;
  916. var
  917.     SysMenu:HMenu;
  918. begin
  919.     TDialog.SetupWindow;
  920.   SetTimer(HWindow,2,5000,nil);
  921.   Is_Timer := True;
  922. end;
  923.  
  924. procedure TOMAboutDlg.WMTimer(var Msg:TMessage);
  925. begin
  926.     KillTimer(HWindow,2);
  927.     Is_Timer := False;
  928.     InvalidateRect(HWindow,nil,True);
  929. end;
  930.  
  931. function TOMAboutDlg.CanClose:Boolean;
  932. begin
  933.   CanClose := True;
  934. end;
  935.  
  936. {************************  TPrgItem    *****************************}
  937. constructor TPgmItem.Init(NewPgmName,NewPgmFile,NewDir,NewParams:PChar;NewCmdShow:Pchar);
  938. begin
  939.     PgmName := StrNew(NewPgmName);
  940.   PgmFile := StrNew(NewPgmFile);
  941.   Dir := StrNew(NewDir);
  942.   Params := StrNew(NewParams);
  943.   CmdShow := StrNew(NewCmdShow);
  944. end;
  945.  
  946. destructor TPgmItem.Done;
  947. begin
  948.     StrDispose(PgmName);
  949.   StrDispose(PgmFile);
  950.   StrDispose(Dir);
  951.   StrDispose(Params);
  952.   StrDispose(CmdShow);
  953. end;
  954.  
  955. {***********************  MainLine  ********************************}
  956. var
  957.     OMApp : TOMApplication;
  958. begin
  959.     OMApp.Init('OttoMenu');
  960.     OMApp.Run;
  961.     OMApp.Done;
  962. end.
  963.